package com.bw.aop;

import com.alibaba.fastjson.JSON;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class Myaop {



    @Around("execution(* com.bw.service.*.*(..))")
    public Object aop(ProceedingJoinPoint joinPoint) throws Throwable {

        String name = joinPoint.getSignature().getName();
        System.out.println("方法名" + name);
        Object[] args = joinPoint.getArgs();
        System.out.println("方法参数 " + JSON.toJSONString(args));

        Object proceed = joinPoint.proceed(); //执行原方法
        System.out.println("方法的返回值" + JSON.toJSONString(proceed));
        return proceed;
    }

}
